Add background attention notifications#1573
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 775c8ba40b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const initializedRef = useRef(false); | ||
|
|
||
| useEffect(() => { | ||
| const nextThreadSnapshot = threads.map((thread) => cloneThreadSnapshot(thread)); |
There was a problem hiding this comment.
Skip snapshot cloning when notifications are off
This effect clones every thread and activity on each threads update before checking attentionNotifications, so the default-off state still pays an O(total activities) copy cost during normal streaming traffic. In production sessions with long activity histories, this can add avoidable render/effect overhead even though no notifications can be emitted. The guard for disabled notifications should run before building full snapshots (or use a cheaper baseline strategy) to avoid this regression.
Useful? React with 👍 / 👎.
Closes #376
Summary
This adds a small first slice of local lifecycle notifications in the web app.
Users can now opt into local attention notifications that fire while T3 Code is in the background when:
What changed
attentionNotificationsclient settingNotes
This stays deliberately small and local:
The goal here is to cover the basic local notification path first while keeping the completion signal tied to the settled turn state instead of intermediate activity.
Validation
Ran in
apps/web:bun x vitest run src/hooks/useLifecycleNotifications.test.tsbun run typecheckbun x oxlint apps/web/src/components/AppSidebarLayout.tsx apps/web/src/components/settings/SettingsPanels.tsx apps/web/src/hooks/useLifecycleNotifications.test.ts apps/web/src/hooks/useLifecycleNotifications.ts apps/web/src/lib/localNotifications.ts apps/web/src/lifecycleNotifications.ts packages/contracts/src/settings.tsNote
Medium Risk
Adds an opt-in, global side effect that observes thread state and triggers browser
NotificationAPI calls, which could cause noisy/duplicated notifications or unexpected behavior across environments if the diffing logic or permission handling is wrong.Overview
Adds opt-in background “attention notifications” to the web app: a new
attentionNotificationsclient setting and a General Settings toggle that requests local notification permission and warns when blocked/unsupported.Introduces lifecycle notification plumbing (
collectLifecycleNotifications+useLifecycleNotifications) to diff thread snapshots and, when the app is not foregrounded, send local notifications for new approvals, new user-input requests, or a newly settled completed turn (with attention requests taking precedence to avoid misleading completion pings). Includes focused unit tests for the notification diffing behavior.Written by Cursor Bugbot for commit 775c8ba. This will update automatically on new commits. Configure here.
Note
Add background attention notifications for thread lifecycle events
attentionNotificationssetting (defaultfalse) inpackages/contracts/src/settings.tsand a toggle in the General Settings panel that requests browser notification permission on enable, surfacing a warning toast if blocked or unsupported.apps/web/src/lifecycleNotifications.tswithcollectLifecycleNotifications, which diffs thread snapshots to emit events for new approval requests, user input requests, and newly settled turn completions, prioritizing attention requests over completions.useLifecycleNotificationshook, mounted in the app layout, which fires local notifications via thelocalNotificationsmodule when the setting is enabled and the app is backgrounded (not visible or not focused).Macroscope summarized 775c8ba.